define('common/common', [
    'require',
    'exports',
    'module',
    '../common/ui/bgMove',
    '../common/config'
], function (require) {
    var uibgMove = require('../common/ui/bgMove');
    var _config = require('../common/config');
    $.fn.bgMove = uibgMove.bgMove;
    return {
        sendRequest: function (url, data, callback) {
            var realCallback = function (data) {
                if (data.errorCode === 0) {
                    callback(data.data);
                } else {
                    alert('\u7cfb\u7edf\u5f02\u5e38');
                }
            };
            $.ajax({
                type: 'POST',
                url: url,
                data: data,
                success: realCallback,
                contentType: 'application/json',
                dataType: 'json'
            });
        },
        sendTextRequest: function (url, callback) {
            var me = this;
            return $.ajax({
                url: url,
                async: false
            }).responseText;
        },
        navInit: function (index) {
            var navs = $('#headBottomContentRight').find('a');
            navs.css('color', '#858585');
            var currentNav = navs.eq(index);
            currentNav.css('color', '#C53334');
            $('#headBottomContentRight').bgMove({
                css: 'heandLinkMoveBg',
                clickClassName: 'heandLink',
                main: $('#headBottomContentRight'),
                fixPlaceEle: currentNav
            });
        },
        switchLanInit: function () {
            $('#switchLan').click(function () {
                var path = $(this).attr('link');
                common.sendRequest(path, {}, common.switchLanCallback);
            });
        },
        switchLanCallback: function (data) {
            if (data == true) {
                location.reload();
            }
        },
        getLocalTime: function (time) {
            var now = new Date(parseInt(time, 10));
            var year = now.getFullYear();
            var month = now.getMonth() + 1;
            var date = now.getDate();
            return year + '-' + month + '-' + date;
        },
        setOutlink: function (ele, url) {
            var me = this;
            me.isOutsideLink(url) ? ele.attr('target', '_blank') : '';
        },
        isOutsideLink: function (url) {
            var re = /^(http|https):\/\//i;
            if (re.test(url)) {
                return true;
            } else {
                return false;
            }
        },
        getURLParam: function getURLParam(key) {
            if (typeof key == 'undefined') {
                return '';
            }
            var raw = location.search.substr(1).split('&'), param = [], tmp = [];
            for (var i = 0, l = raw.length; i < l; i++) {
                tmp = raw[i].split('=');
                param[tmp[0]] = tmp[1];
            }
            if (typeof param[key] != 'undefined') {
                return param[key];
            } else {
                return '';
            }
        },
        isAllEn: function (str) {
            var reg = /^[u4E00-u9FA5]+$/;
            return !reg.test(str);
        },
        getUserid: function () {
            return $.cookie(_config.COOKIE_NAME);
        }
    };
});